package main

import "fmt"

//import "fmt"

type stru struct {
	name string
	age  int
	_sex string
}
type person struct {
	name string
	age  int
	contact struct {
		phone string
		city  string
	}
}
type any struct {
	string
	int
}
type anyone struct {
	string
	int
}

type human struct {
	sex string
}
//引入其他结构体
type women struct {
	human		//匿名字段
	name string
	age int
}
type man struct {
	human
	name string
	age int
}
func main() {
	var sr *stru = new(stru) //定义的是指向结构体的指针
	sr._sex = "gril"
	sr.age = 18
	sr.name = "enen"
	fmt.Println(sr)
	//传参值 copy
	test(*sr)
	fmt.Println(sr)


	fmt.Println("====================")
	//传递指针
	testPointer(sr)
	fmt.Println(sr)


	fmt.Println("====================")
	s := stru{ //定义结构体，而不是指向结构的指针
		name: "A3",
		age:  22,
		_sex: "girl",
	}
	fmt.Println(s)
	test(s)
	//“&”取指针
	testPointer(&s)


	fmt.Println("=============================")
	p := person{
		name: "A3-grle",
		age:  22,
	}
	p.contact.phone = "12465987122"
	p.contact.city = "深圳"
	fmt.Println(p)


	fmt.Println("=============================")
	an := any{"A3", 20}
	fmt.Println(an)


	fmt.Println("=============================")
	w:=women{human:human{sex:"gile"},name:"meinv",age:22}
	m:=man{name:"men",age:22,human:human{sex:"man"}}
	fmt.Println(w)
	fmt.Println(m)
	fmt.Println(m.name,m.age,m.sex)
}
func test(st stru) {
	st.name = "A3"
	st.age = 23
	fmt.Println("test", st)
}
func testPointer(st *stru) {
	st.name = "A3-pointer"
	st.age = 23
}
func anyonestruct() {
	a := struct {
		name string
		age  int
	}{
		name: "any",
		age:  23,
	}
	fmt.Println(a)

	a1 := &struct {
		name string
		age  int
	}{
		name: "any",
		age:  23,
	}
	fmt.Println(a1)

}
